export type MenuType = 0 | 1 | 2

type MenuBaseType = {
    menuType: MenuType
    parentId: string
    name: string
    url: string
    component: string
    componentName: string
    redirect: string
    icon: string
    sortNo: number
    isRoute: number
    hidden: number
    hideTab: number
    alwaysShow: number
    internalOrExternal: number
    perms?: string
    permsType?: number
    status?: string
}

// 针对 menuType 为 2 时的必填类型
type MenuType2RequiredFields = {
    perms: string;
    permsType: number;
    status: number;
    component?: string
    componentName?: string
    redirect?: string
    icon?: string
    sortNo?: number
    isRoute?: number
    hidden?: number
    hideTab?: number
    alwaysShow?: number
    internalOrExternal?: number
};

// 菜单添加动态条件类型
export type MenuAddType = MenuBaseType & (MenuType extends 2 ? MenuType2RequiredFields : {});
// 菜单编辑
export type MenuEditType = {
    id: string
} & MenuAddType

// 菜单列表返回
export type MenuListResType = {
    alwaysShow: boolean
    children: MenuListResType[]
    component: string
    componentName?: string
    createBy: null
    createTime: null
    delFlag: number
    description: null
    hidden: number
    hideTab: number
    icon: string
    id: string
    internalOrExternal: number
    keepAlive: number
    key: string
    isLeaf: boolean
    menuType: MenuType
    name: string
    parentId: string
    perms: string;
    permsType: number;
    redirect: string
    route: number
    sortNo: number
    status: number
    title: string
    updateBy: null
    updateTime: null
    url: string
}
